export default defineNuxtConfig({
  // 服务器渲染和部署配置
  nitro: {
    prerender: {
      crawlLinks: true, // 预渲染所有链接页面
      routes: ['/'], // 首页预渲染
    },
    compressPublicAssets: true, // 压缩静态资源
  },
  
  // 开发工具
  devtools: { enabled: true },
  
  // 运行时配置
  runtimeConfig: {
    giteeToken: process.env.GITEE_TOKEN,
    giteeAuthorName: process.env.GITEE_AUTHORNAME,
    public: {
      siteUrl: process.env.SITE_URL || 'https://flanchan.dev',
      siteName: 'FlanChanBlog',
      siteDescription: '技术分享与学习笔记',
      language: 'zh-CN',
    }
  },
  
  // 应用配置
  app: {
    head: {
      charset: 'utf-8',
      viewport: 'width=device-width, initial-scale=1',
      title: 'Flan-Chan Blog',
      meta: [
        { name: 'description', content: '技术分享与学习笔记,专注于Java、微服务和前端开发' },
        { name: 'theme-color', content: '#41b883' },
      ],
      link: [
        { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
        { 
          rel: 'stylesheet',
          href: 'https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;700&display=swap',
          crossorigin: 'anonymous'
        },
        { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
        { rel: 'preconnect', href: 'https://fonts.gstatic.com', crossorigin: 'anonymous' }
      ]
    },
    pageTransition: { name: 'page', mode: 'out-in' },
    layoutTransition: { name: 'layout', mode: 'out-in' },
  },
  
  // 深色模式配置
  colorMode: {
    classSuffix: "",
    preference: "system", // 默认跟随系统
    fallback: "light", // 回退到亮色主题
    storageKey: "nuxt-color-mode",
  },
  
  // 内容配置
  content: {
    build: {
      // Markdown 配置
      markdown: {
        toc: {
          depth: 3,
          searchDepth: 3,
        },
        // 代码高亮配置
        highlight: {
          theme: {
            default: "vitesse-light",
            light: "vitesse-light",
            dark: "vitesse-dark",
          },
          langs: [
            "bash",
            "c",
            "cpp",
            "java",
            "json",
            "js",
            "ts",
            "html",
            "css",
            "vue",
            "ts",
            "tsx",
            "jsx",
            "shell",
            "mdc",
            "md",
            "yaml",
          ],
        },
      },
    },
  },
  
  // 模块列表
  modules: [
    "@nuxt/content", 
    "@nuxtjs/tailwindcss", 
    "@nuxtjs/color-mode",
    "@vueuse/nuxt",
    // 暂时移除有问题的模块 与nuxt/contentV3冲突 可以手动配置写入robots.txt和sitemap.xml
    // "@nuxtjs/robots",
    // "@nuxtjs/sitemap",
  ],
  
  // 组件配置
  components: {
    global: true, // 启用全局组件
    dirs: ["~/components", "~/layouts"],
  },
  
  // 导入配置
  imports: {
    autoImport: true, // 确保自动导入
    dirs: ['composables', 'utils'],
  },
  
  // CSS 样式文件
  css: ["~/assets/css/main.css"],
  
  // PostCSS 配置
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {},
    },
  },
  
  // 兼容性日期，让 Nuxt 能够引入新特性
  compatibilityDate: "2024-11-01",
  
  // 构建配置
  build: {
    transpile: ["@nuxt/content"],
  },
});
